<template>
	<el-dialog :title="title" v-model="visible" :width="950" destroy-on-close @closed="$emit('closed')">
		<el-header style="height: auto;">
			<div class="left-panel"></div>
			<div class="right-panel">
				<el-input v-model="search.staff_name" placeholder="姓名"></el-input>
				<el-input v-model="search.mobile" placeholder="员工手机"></el-input>
				<el-button type="primary" icon="el-icon-search" @click="upsearch"></el-button>
				<el-button type="info" @click="resetUpsearch">重置</el-button>
			</div>
		</el-header>
		<scTable ref="table" :apiObj="apiObj" @selection-change="selectionChange" stripe remoteSort remoteFilter>
			<el-table-column type="selection" width="50"></el-table-column>
			<el-table-column label="员工编码" prop="staff_id" width="100" sortable='custom'></el-table-column>
			<el-table-column label="用户编码" prop="user_id" width="100"></el-table-column>
			<el-table-column label="姓名" prop="staff_name" width="150"></el-table-column>
			<el-table-column label="所属部门" prop="dept_name" width="150"></el-table-column>
			<el-table-column label="创建时间" prop="created_at" width="170"></el-table-column>
		</scTable>
		<template #footer>
			<el-button @click="visible = false">关 闭</el-button>
			<el-button type="primary" :loading="isSaveing" @click="submit()">确 认</el-button>
		</template>
	</el-dialog>
</template>

<script>
export default {
	emits: ['success', 'closed'],
	data() {
		return {
			title: "选择员工",
			visible: false,
			isSaveing: false,
			apiObj: this.$API['admin.user'].list,
			selection: null,
			search: {
				staff_name: null,
				mobile: null,
			}
		}
	},
	mounted() {
	},
	methods: {
		//显示
		open() {
			this.visible = true;
			return this
		},
		//显示
		close() {
			this.visible = false;
			return this
		},
		//表单提交方法
		submit() {
			this.$emit('success', this.selection)
		},
		//表格选择后回调事件
		selectionChange(selection) {
			this.selection = selection;
		},
		//搜索
		upsearch() {
			this.$refs.table.upData(this.search)
		},

		//搜索重置
		resetUpsearch() {
			this.search = {};
			this.$refs.table.reload(this.search)
		},

	}
}
</script>

<style></style>
